<template>
  <div class="home">
    <Head />
    <div style="margin-top:20px;clear:both"></div>
    <div   v-for="(item,index) in articleList"
                :key="index">
      <h1>{{item.title}}</h1>
      <div>{{item.content}}</div>
    </div>
  </div>
</template>
<script>
import Head from "../components/Head";
import { getPosts } from "../api/list";
export default {
  name: "home",
  components: {
    Head
  },

  data() {
    return {
    articleList:[

    ]
    }
  },
  created() {
    this.getArticle();
  },
  methods: {
    getArticle() {
     
      getPosts()
        .then(res => {
          console.log(res)
          if (res.status === 200) {
            this.articleList = res.data;
          } else {
            this.$message.error(res);
          }
        })
        .catch(err => {
          console.log(err);

          //alert(err)
        });
    }
  }
};
</script>
<style lang="scss">
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: left;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
